package com.chen.positioning.util;

import com.chen.positioning.mypositioning.controller.MypositioningController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@Service
public class RandomNumber {
    private static final Logger logger = LoggerFactory.getLogger(MypositioningController.class);

    public List<String> generation(List<String> oldList) throws Exception{
        List<String> newList = new ArrayList<String>();
        logger.info("old list :"+oldList.get(0)+"---"+oldList.get(1));
        int num1 = new Random().nextInt(100000 - 5000) + 1000;
        int num2 = new Random().nextInt(100000 - 5000) + 1000;
        System.out.println("随机数---num1:" + num1 + ",num2:" + num2);
        String a = oldList.get(0);
        String b = oldList.get(1);
        String[] jidu = a.split("\\.");
        if (null != jidu && jidu.length > 1) {//1234.2345
            //前面的不变，只改后面的数字 get(0)不变 get(1)变
            long count_jd = Integer.parseInt(jidu[1]) + num1;
            logger.info(" count_jd:" + count_jd);
            newList.add(jidu[0] + "." + count_jd);
        }
        String[] weidu = b.split("\\.");
        if (null != weidu && weidu.length > 1) {//1234.2345
            //前面的不变，只改后面的数字 get(0)不变 get(1)变
            long count_wd = Integer.parseInt(weidu[1]) + num2;
            logger.info(" count_wd:" + count_wd);
            newList.add(weidu[0] + "." + count_wd);
        }
        logger.info("newlist:" + newList.get(0) + "----" + newList.get(1));
        return newList;
    }
}
